<template>
    <el-dialog v-model="open" title="修改配置" width="510px">
        <el-form ref="formRef" :model="formData" :rules="formRules" label-width="140px">
            <el-form-item label="HF" prop="hf">
                <el-input v-model="formData.hf" placeholder="请输入HF" />
            </el-form-item>
            <el-form-item label="HF2" prop="hf2">
                <el-input v-model="formData.hf2" placeholder="请输入hf2" />
            </el-form-item>
            <el-form-item label="质押天数" prop="lockDay">
                <el-input v-model="formData.lockDay" placeholder="请输入质押天数" />
            </el-form-item>
            <el-form-item label="增加收益" prop="selfaddrate">
                <el-input v-model="formData.selfaddrate" placeholder="请输入增加收益" />
            </el-form-item>
            <el-form-item label="动态HF2有效比例" prop="uphf2rate">
                <el-input v-model="formData.uphf2rate" placeholder="请输入动态HF2有效比例" />
            </el-form-item>
            <el-form-item prop="status">
                <el-radio-group v-model="formData.status">
                    <el-radio :label="0" size="large">上架</el-radio>
                    <el-radio :label="1" size="large">下架</el-radio>
                </el-radio-group>
            </el-form-item>

        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button type="primary" :loading="loading" @click="onSubmit('formData')">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script setup>
import { reactive, ref, defineExpose, defineEmits } from "vue";
import { setStakePlan } from "@/api";
import { ElMessageBox, ElMessage } from "element-plus";
const emit = defineEmits(["loadData"]);
const formRef = ref();
const open = ref(false);
const formData = reactive({
    id: "",
    hf: "",
    hf2: "",
    lockDay: "",
    status: "",
    selfaddrate: "",
    uphf2rate: "",
});
const formRules = {};
const loading = ref(false);
const onSubmit = async () => {
    try {
        const a = await formRef.value.validate().catch(() => null);
        if (!a) return;
        open.value = false;
        const res = await setStakePlan(formData);
        if (res.data.code == 20) {
            ElMessage({
                message: "成功",
                type: "success",
            });
        }
        emit("loadData");
    } catch (error) {}
};
const show = (row) => {
    open.value = true;
    formData.id = row.Id;
    formData.hf = row.HF;
    formData.hf2 = row.HF2;
    formData.lockDay = row.LockDay;
    formData.status = row.Status;
    formData.selfaddrate = row.SelfAddRate;
    formData.uphf2rate = row.UpHF2Rate;
    console.log(row);
};
defineExpose({
    show,
});
</script>
<style lang="scss" scoped>
.right {
    overflow: auto;
}

.el-pagination {
    padding: 15px;
    float: right;
}
</style>